package com.ybt.message.pack;

import org.jdom.Element;

import com.ruleengine.context.IWorkflowConext;
import com.ybt.message.pack.exception.MessagePackException;

public abstract class MessagePackDecorator implements IMessagePack {

    IMessagePack pack;
    protected Element config;
    
    public MessagePackDecorator(IMessagePack pack) {
        super();
        this.pack = pack;
    }

    public void setUnpackConfig(Element config) {
        this.config = config;
    }

    public Object pack(IWorkflowConext context, Object message)
            throws MessagePackException{
        Object result = pack.pack(context, message);
        return packMessage(context, result);
    }

    public abstract Object packMessage(IWorkflowConext context, Object message)
    throws MessagePackException;
}
